package com.zl.zsk.config.security;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.zl.zsk.pojo.vo.Result;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author lxb
 * @version 1.0.0
 * @desc:
 * @date 2020-03-13 17:00
 */
public class HandleSuccessAuthentication implements AuthenticationSuccessHandler {
    @Override
    public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
        response.setContentType("text/json;charset=utf-8");
        ObjectMapper objectMapper = new ObjectMapper();
        Result result = new Result();
        response.getWriter().write(objectMapper.writeValueAsString(result));
    }
}
